//
//  VKReNextLevelCell.m
//  V-Learn
//
//  Created by liubo on 2019/1/10.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKReNextLevelCell.h"

@implementation VKReNextLevelCell{
    UILabel *_titleLabel;
    UILabel *_lineLabel;
    UILabel *_timeLabel;
    UILabel *_countLabel;
    UIImageView *_imageView;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKReNextLevelCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKReNextLevelCell"];
    if (cell == nil) {
        cell = [[VKReNextLevelCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKReNextLevelCell"];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 点击cell的时候不要变色
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        // 布局子控件
        [self autoLayout];
    }
    return self;
}

-(void)setModel:(VKReNextLevelModel *)model{
    _model = model;
    NSString *urlString = [NSString stringWithFormat:@"%@%@",Public_URL,model.headImage];
    [_imageView sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:@"logo"]];
    _timeLabel.text = [model.createDate substringToIndex:10];
    _titleLabel.text = model.username;
    _countLabel.text = [NSString stringWithFormat:@"+%@",model.earnPrice];
}

- (void)autoLayout{
    
    _imageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_imageView];
    _imageView.image = [UIImage imageNamed:@"girl"];
    _imageView.layer.cornerRadius = 20;
    _imageView.layer.masksToBounds = YES;
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.width.height.equalTo(@40);
        make.centerY.equalTo(self.contentView);
    }];
    
    UILabel *titleLabel = [[UILabel alloc]init];
    [self.contentView addSubview:titleLabel];
    _titleLabel = titleLabel;
    titleLabel.font = [UIFont systemFontOfSize:16];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"注册成功";
    titleLabel.textColor = [UIColor cz_colorWithRed:40 green:40 blue:40];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_imageView.mas_right).offset(10);
        make.top.mas_equalTo(_imageView).offset(2);
    }];
    
    UILabel *countLabel = [[UILabel alloc]init];
    _countLabel = countLabel;
    [self.contentView addSubview:countLabel];
    countLabel.font = [UIFont systemFontOfSize:17];
    countLabel.text = @"+21";
    countLabel.textColor = [UIColor cz_colorWithRed:253 green:79 blue:83];
    [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(self.contentView);
    }];
    UILabel *timeLabel = [[UILabel alloc]init];
    [self.contentView addSubview:timeLabel];
    timeLabel.font = [UIFont systemFontOfSize:14];
    timeLabel.text = @"2018-10-01";
    timeLabel.textColor = [UIColor cz_colorWithRed:162 green:162 blue:162];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleLabel);
        make.top.mas_equalTo(titleLabel.mas_bottom).offset(2.6);
    }];
    UILabel *lineLabel = [[UILabel alloc]init];
    [self.contentView addSubview:lineLabel];
    lineLabel.backgroundColor = [UIColor cz_colorWithRed:244 green:244 blue:244];
    [lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(self.contentView);
        make.height.equalTo(@1);
    }];
    
}

@end
